<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title></title>
  <link rel="stylesheet" href="/css/main.css"/>
  <link rel="stylesheet" href="/cms/layui/css/layui.css">
  <script src="/js/uikit.js"></script>
</head>

<body>

<div th:insert="~{common::#header}"></div>

<div class="uk-section uk-section-muted">
  <div class="uk-container">
    <div class="uk-background-default uk-border-rounded uk-box-shadow-small">
      <div class="uk-container uk-container-xsmall uk-padding-large">
        <article class="uk-article">
          <h1 class="uk-article-title" style="text-align: center;">管理我的标签信息</h1>
          <div class="uk-article-content">
            <form class="uk-form-stacked uk-margin-medium-top layui-form" onsubmit="return false;">



              <div class="uk-margin-bottom">
                <label class="uk-form-label" for="tag">标签</label>
                <div class="uk-form-controls">
                  <input id="tag" class="uk-input uk-border-rounded" placeholder="键入Enter添加" autocomplete="off" type="text">
                </div>
              </div>


              <button class="layui-btn" style="background-color: #583ABC" th:each="tag:${tags}">
                <span th:text="${tag.tagName}"></span>
                <span class="layui-badge layui-bg-gray" style="background-color: #ff1200!important;color: #fff!important;" th:onclick="deleteTag([[${tag.id}]])">
                  删除</span>
              </button>


            </form>
          </div>
        </article>
      </div>
    </div>
  </div>
</div>


<script src="/js/awesomplete.js"></script>
<script src="/js/custom.js"></script>
<script src="/cms/layui/layui.js" charset="utf-8"></script>

<script>
  layui.use(['layedit', 'form'], function () {
    var form = layui.form;
    var $ = layui.$;

    document.onkeydown = function(e){
      if(e.keyCode == 13){
       var tag = $("#tag").val();
       if (!tag) {
         layer.msg("请输入标签！");
         return false;
       }

       window.location.href='/tag/add?tagName='+tag;

      }
    }

  });

  function deleteTag(index) {
    if(!confirm("确定删除？")){
      return false;
    }
    window.location.href='/tag/delete?tagId='+index;

  }
</script>

</body>

</html>